package net.mikoo.seals.boss.biz.services.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Service
public class ${info.entityName}ServicesImpl extends BaseServices implements ${info.entityName}Services {
	
	Logger logger = LoggerFactory.getLogger(${info.entityName}ServicesImpl.class);

	@Autowired
	private ${info.entityName}Mapper ${info.variableName}Mapper;
	
	@Override
	public void save(${info.entityName} ${info.variableName}) {
		
		if(${info.variableName} == null){
			throw new ParametersException("${info.variableName} is null!");
		}
		
		${info.variableName}Mapper.insert(${info.variableName});
	}

	@Override
	public void modify(${info.entityName} ${info.variableName}) {
		
		if(${info.variableName} == null){
			throw new ParametersException("${info.variableName} is null!");
		}
		${info.variableName}Mapper.delete(${info.variableName});
	}
	
	@Override
	public ${info.entityName} getInfoById(Long ${info.entityName}Id) {
		
		if(${info.entityName}Id == null){
			throw new ParametersException("${info.entityName}Id is null!");
		}
		
		${info.entityName} ${info.entityName} = ${info.variableName}Mapper.selectInfoById(${info.entityName}Id);
		return ${info.entityName};
	}
	
	
	
	@Override
	public PageModel<${info.entityName}> getPageByQuery(${info.entityName}Query query) {
		
		
		List<${info.entityName}> datas = ${info.variableName}Mapper.selectPageByQuery(query);
		Integer total = ${info.variableName}Mapper.countPageByQuery(query);
		PageModel<${info.entityName}> pm = new PageModel<${info.entityName}>(total,datas);
		return pm;
	}

	
}
